<?php
/*
 * 进云智能生成平台
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
 */

defined('BY_JYA') or exit('error');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['setting']=$this->plugin_setting('basic');
$uniacid=$_SESSION['uniacid'];
if($_RQ['op']=='main'){
	//我的贡献
	$mycount=pdo_getcolumn('jy_smallquan_household',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'pmoney');
	
	$sql = "SELECT SUM(pmoney) FROM " . tablename('jy_smallquan_household') . " WHERE uniacid=:uniacid";
    $money = pdo_fetch($sql,array(":uniacid" => $_SESSION['uniacid']));
	$return['count'] = $money['SUM(pmoney)'];
	$return['params']=array('keyword'=>'');
	$return['date']=date('Y-m-d h:i',time());
	$return['post']=array();
	$return['mycount']=$mycount;
	
	exi($return);
}
if($_RQ['op']=='getlist'){
	if(!empty($_RQ['keyword'])){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
		$return['params']['keyword']=$_RQ['keyword'];
	}
	//$params['status']=1;
	$uniacid=$_SESSION['uniacid'];
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','mid','hid','status','name','shenfen','mobile','pmoney','createtime');
	$list=pdo_getslice('jy_smallquan_household',$params,array($pindex,$psize),$total,$fields,'','pmoney desc');
	if($list){
		$i=0;
		foreach($list as &$item){
			$member=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['mid']));
			$item['member']=$member;
			$item['createtime']=date('y-m-d h:i',$item['createtime']);
			$i=$i+1;
			$item['paiming']=$i;
		}
	}
	$return['list']=$list;
	//print_r($list);exit;
	exi($return);
	
}

		
		


